import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:moose_app/ui/values/values.dart';
import 'package:moose_app/ui/widgets/common/common_comment_item.dart';
import 'package:moose_app/ui/widgets/pagination/custom_pagination.dart';

class ATHDetailRecordBody extends StatefulWidget {
  @override
  _ATHDetailRecordBodyState createState() => _ATHDetailRecordBodyState();
}

class _ATHDetailRecordBodyState extends State<ATHDetailRecordBody> {
  final bannerImages = [
    "https://gitee.com/shizidada/moose-resource/raw/master/banner/banner-1.jpg",
    "https://gitee.com/shizidada/moose-resource/raw/master/banner/banner-3.jpg",
    "https://gitee.com/shizidada/moose-resource/raw/master/banner/banner-2.jpg",
  ];

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [_buildDetailSwiper(), _buildContent(), _buildComment()],
      ),
    );
  }

  Widget _buildComment() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: kSize20).copyWith(top: kSize20),
      child: ListView.builder(
          shrinkWrap: true,
          physics: NeverScrollableScrollPhysics(),
          itemCount: 6,
          itemBuilder: (context, index) {
            return ATHCommonCommentItem();
          }),
    );
  }

  Widget _buildContent() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: kSize20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.symmetric(vertical: kSize16),
            child: Text(
              "蜀道难",
              style: TextStyle(fontSize: kFontSize36, color: kColor33),
            ),
          ),
          Container(
            child: Text(
              "噫吁嚱，危乎高哉！蜀道之难，难于上青天！\n蚕丛及鱼凫，开国何茫然！尔来四万八千岁，不与秦塞通人烟。西当太白有鸟道，可以横绝峨眉巅。地崩山摧壮士死，然后天梯石栈相钩连。\n上有六龙回日之高标，下有冲波逆折之回川。黄鹤之飞尚不得过，猿猱欲度愁攀援。青泥何盘盘，百步九折萦岩峦。扪参历井仰胁息，以手抚膺坐长叹。\n 问君西游何时还？畏途巉岩不可攀。但见悲鸟号古木，雄飞雌从绕林间。又闻子规啼夜月，愁空山。蜀道之难，难于上青天，使人听此凋朱颜。\n连峰去天不盈尺，枯松倒挂倚绝壁。飞湍瀑流争喧豗，砯崖转石万壑雷。其险也如此，嗟尔远道之人胡为乎来哉！\n剑阁峥嵘而崔嵬，一夫当关，万夫莫开。所守或匪亲，化为狼与豺。朝避猛虎，夕避长蛇；磨牙吮血，杀人如麻。锦城虽云乐，不如早还家。蜀道之难，难于上青天，侧身西望长咨嗟。",
              style: TextStyle(fontSize: kFontSize32, color: kColor33),
            ),
          ),
//          Container(
//            child: Text(
//              "遥远的路途，坎坷崎岖，难以预设，难以掌握，但风景依然，心依然; \n\n一路的奔波，尽管劳碌，难以寄托，难以言说，可不再重来，也回不到最初; \n\n许是越走越累，许是越走越轻松，许是越走越无奈，可总得要走，不停的走，一直朝前走……",
//              style: TextStyle(fontSize: kFontSize30),
//            ),
//          ),
          Container(
            margin: EdgeInsets.only(top: kSize20),
            padding: EdgeInsets.all(kSize8),
            decoration: BoxDecoration(
                color: kColorPrimaryLight,
                borderRadius: BorderRadius.circular(kSize8)),
            child: Text(
              "你在干什么？",
              style: TextStyle(color: kColorPrimary),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: kSize20),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "02-10",
                  style: TextStyle(fontSize: kFontSize24, color: kColor33),
                ),
                Text(
                  "不喜欢",
                  style: TextStyle(fontSize: kFontSize24, color: kColor33),
                )
              ],
            ),
          ),
          Divider(),
          Text("共 1889 条评论")
        ],
      ),
    );
  }

  Widget _buildDetailSwiper() {
    return Container(
      height: kSize700,
      child: Swiper(
        controller: SwiperController(),
        itemCount: bannerImages.length,
        itemBuilder: (BuildContext context, int position) {
          String imagePath = bannerImages[position];
          return CachedNetworkImage(imageUrl: imagePath, fit: BoxFit.fill);
        },
        loop: false,
        scrollDirection: Axis.horizontal,
        pagination: SwiperPagination(
            margin: EdgeInsets.only(top: kSize20),
            alignment: Alignment.bottomCenter,
            builder: CustomSwiperPaginationBuilder(activeColor: kColorPrimary)),
      ),
    );
  }
}
